package com.huawei.zyb.taskManager.domain.task.valueobject;

/**
 * 任务层级枚举值对象
 * 支持最多3级任务层级
 */
public enum TaskLevel {
    LEVEL_1("主任务", 1),
    LEVEL_2("子任务", 2),
    LEVEL_3("子子任务", 3);

    private final String description;
    private final int level;

    TaskLevel(String description, int level) {
        this.description = description;
        this.level = level;
    }

    public String getDescription() {
        return description;
    }

    public int getLevel() {
        return level;
    }

    /**
     * 获取下一级任务层级
     */
    public TaskLevel getNextLevel() {
        return switch (this) {
            case LEVEL_1 -> LEVEL_2;
            case LEVEL_2 -> LEVEL_3;
            case LEVEL_3 -> throw new IllegalStateException("已达到最大任务层级，不能再创建子任务");
        };
    }

    /**
     * 检查是否可以创建子任务
     */
    public boolean canHaveSubTask() {
        return this != LEVEL_3;
    }

    /**
     * 检查是否为根任务
     */
    public boolean isRootLevel() {
        return this == LEVEL_1;
    }

    /**
     * 检查是否为最深层级
     */
    public boolean isDeepestLevel() {
        return this == LEVEL_3;
    }
}